package com.aubrey.threadDemo.create;

/**
 * @author aubrey
 * @create 2018-10-26 13:39
 */
public class VolatileDemo2 {

    private static volatile  int count = 0;
    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            new Thread(()->{
                for (int j = 0; j < 1000; j++) {
                    count++;
//                    System.out.println(Thread.currentThread().getName()+":"+count);
                }
            }).start();
        }
        while (Thread.activeCount() > 1)Thread.yield();
        System.out.println("main==========="+count);
    }
}
